// 轻提示
export function toast(info = {}, navigateOpt) {
  let title = info.title || "";
  let icon = info.icon || "none";
  let endtime = info.endtime || 2000;
  if (title)
    uni.showToast({
      title: title,
      icon: icon,
      duration: endtime,
    });
  if (navigateOpt != undefined) {
    if (typeof navigateOpt == "object") {
      let tab = navigateOpt.tab || 1,
        url = navigateOpt.url || "";
      switch (tab) {
        case 1:
          //跳转至 table
          setTimeout(function () {
            uni.switchTab({
              url: url,
            });
          }, endtime);
          break;
        case 2:
          //跳转至非table页面
          setTimeout(function () {
            uni.navigateTo({
              url: url,
            });
          }, endtime);
          break;
        case 3:
          //返回上页面
          setTimeout(function () {
            uni.navigateBack({
              delta: parseInt(url),
            });
          }, endtime);
          break;
        case 4:
          //关闭当前所有页面跳转至非table页面
          setTimeout(function () {
            uni.reLaunch({
              url: url,
            });
          }, endtime);
          break;
        case 5:
          //关闭当前页面跳转至非table页面
          setTimeout(function () {
            uni.redirectTo({
              url: url,
            });
          }, endtime);
          break;
      }
    } else if (typeof navigateOpt == "function") {
      setTimeout(function () {
        navigateOpt && navigateOpt();
      }, endtime);
    }
  }
}

export function getTimestamp() {
	let date = new Date();
	let month = Number(date.getMonth()) + 1;
	let time = date.getFullYear() + "/" + month + "/" + date.getDate();
	var timestamp = Date.parse(date.getFullYear() + "/" + month + "/" + date.getDate()) / 1000;
	return timestamp
}